import request from '@/config/axios'

// 机台产线基础信息 VO
export interface BaseMachineInfoVO {
  id: string // 机台信息ID
  machineName: string // 机台名称
  machineCode: string // 机台代码
  machineProperty: string // 机台参数
  machineBrand: string // 机台品牌
  hasWeight: boolean // 是否有电子秤
  weightNum: number // 电子秤数量
  isScheduling: boolean // 是否用于人力排班
  isMachine: boolean // 是否是机台
  orderNo: number // 显示顺序
  workShopId: string // 车间ID
  machineAreaId: string // 区域ID
  machinePlcId: string // PLC编号
  projectId: string // 项目编号
  regionId: string // 区域编号
  status: number // 设备状态
  offline: boolean // 是否在线

}

// 机台产线基础信息 API
export const BaseMachineInfoApi = {

  // 查询机台产线基础信息分页
  getAllBaseMachineInfoList: async () => {
    return await request.get({ url: `/mes/base-machine-info/list-all-simple` })
  },
  // 查询机台产线基础信息分页
  getBaseMachineInfoPage: async (params: any) => {
    return await request.get({ url: `/mes/base-machine-info/page`, params })
  },

  // 查询机台产线基础信息详情
  getBaseMachineInfo: async (id: number) => {
    return await request.get({ url: `/mes/base-machine-info/get?id=` + id })
  },

  // 新增机台产线基础信息
  createBaseMachineInfo: async (data: BaseMachineInfoVO) => {
    return await request.post({ url: `/mes/base-machine-info/create`, data })
  },

  // 修改机台产线基础信息
  updateBaseMachineInfo: async (data: BaseMachineInfoVO) => {
    return await request.put({ url: `/mes/base-machine-info/update`, data })
  },

  // 删除机台产线基础信息
  deleteBaseMachineInfo: async (id: number) => {
    return await request.delete({ url: `/mes/base-machine-info/delete?id=` + id })
  },

  // 导出机台产线基础信息 Excel
  exportBaseMachineInfo: async (params) => {
    return await request.download({ url: `/mes/base-machine-info/export-excel`, params })
  },

// ==================== 子表（设备数据） ====================

  // 获得设备数据分页
  getBaseDeviceDataPage: async (params) => {
    return await request.get({ url: `/mes/base-machine-info/base-device-data/page`, params })
  },
  // 新增设备数据
  createBaseDeviceData: async (data) => {
    return await request.post({ url: `/mes/base-machine-info/base-device-data/create`, data })
  },

  // 修改设备数据
  updateBaseDeviceData: async (data) => {
    return await request.put({ url: `/mes/base-machine-info/base-device-data/update`, data })
  },

  // 删除设备数据
  deleteBaseDeviceData: async (id: number) => {
    return await request.delete({ url: `/mes/base-machine-info/base-device-data/delete?id=` + id })
  },

  // 获得设备数据
  getBaseDeviceData: async (id: number) => {
    return await request.get({ url: `/mes/base-machine-info/base-device-data/get?id=` + id })
  },

  // ==================== 子表（机台负责人员信息） ====================

  // 获得机台负责人员信息分页
  getBaseMachinePeopleInfoPage: async (params) => {
    return await request.get({ url: `/mes/base-machine-info/base-machine-people-info/page`, params })
  },
  // 新增机台负责人员信息
  createBaseMachinePeopleInfo: async (data) => {
    return await request.post({ url: `/mes/base-machine-info/base-machine-people-info/create`, data })
  },

  // 修改机台负责人员信息
  updateBaseMachinePeopleInfo: async (data) => {
    return await request.put({ url: `/mes/base-machine-info/base-machine-people-info/update`, data })
  },

  // 删除机台负责人员信息
  deleteBaseMachinePeopleInfo: async (id: number) => {
    return await request.delete({ url: `/mes/base-machine-info/base-machine-people-info/delete?id=` + id })
  },

  // 获得机台负责人员信息
  getBaseMachinePeopleInfo: async (id: number) => {
    return await request.get({ url: `/mes/base-machine-info/base-machine-people-info/get?id=` + id })
  },
}
